package com.jdym.controller;


import com.jdym.R;
import com.jdym.entity.Certify;
import com.jdym.entity.Check;
import com.jdym.service.CertifyService;
import com.jdym.service.CheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 资质认证审核表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-09-20
 */
@RestController
@RequestMapping("/certify")
public class CertifyController {
    @Autowired
    CertifyService certifyService;
    @Autowired
    CheckService checkService;
//    提交审核
    @PostMapping("/verifyRequest")
    public R verifyRequest( Check check){
        System.out.println("============");
        System.out.println(check.getCertifyId());
        System.out.println("check:"+check);
//        提交申请，插入申请
     checkService.insertCertify(check);
//     获取插入的cheid

        System.out.println("cheId:"+check.getCheId());
        int cheId=check.getCheId();
        Certify certify=new Certify();
        certify.setCertifyId(check.getCertifyId());
        certify.setCheckId(cheId);
        certifyService.getBaseMapper().updateById(certify);
        return R.ok().data("cheId",cheId);
    }
//    根据cheid查找提交申请的状态
    @RequestMapping(value = "/getCheckStatus/{cheId}")
    public R getCheckStatus(@PathVariable int cheId){

    Check check= checkService.selectStatus(cheId);

    return R.ok().data("check",check);
    }

}

